package toDo.app.controllers;

import interfaces.IToDoListActivity;

import toDo.app.CreateToDoActivity;
import toDo.app.EditToDoActivity;
import toDo.app.R;
import toDo.app.models.RequestCodes;
import toDo.app.models.ToDoListItem;
import toDo.app.models.User;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;

public class ToDoListActivityClickController implements OnClickListener {
	private IToDoListActivity activity;
	private Class<?> createActivity;
	private Class<?> editActivity;
	private Class<?> mapActivity;

	public ToDoListActivityClickController(IToDoListActivity activity, Class<?> createActivity, Class<?> editActivity,
			Class<?> mapActivity) {
		this.activity = activity;
		this.createActivity = createActivity;
		this.editActivity = editActivity;
		this.mapActivity = mapActivity;
	}

	@Override
	public void onClick(View v) {
		activity.setCategoryVisibility(false);

		switch(v.getId()) {
		/*
		 * case R.id.toDoListAfterDateButton: new DatePickerDialog(activity,
		 * this, dateAndTime.get(Calendar.YEAR),
		 * dateAndTime.get(Calendar.MONTH),
		 * dateAndTime.get(Calendar.DAY_OF_MONTH)).show(); break;
		 */
			case R.id.toDoListNewItemLButton:
				activity.startActivityForResult(
						User.putUserIntoIntent(new Intent(activity, CreateToDoActivity.class), activity.getUser()),
						RequestCodes.createItem);
				break;

			case R.id.toDoListLogOutLButton:
				activity.finish();
				break;
				//activity.startActivity(ToDoListItem.putItemIntoIntent(new Intent(v.getContext(), mapActivity),
						//activity.getItem()));
				/*
				 * case R.id.toDoListAllButton:
				 * activity.setList(DatabaseFacade.getList(activity,
				 * activity.getUser())); break; case
				 * R.id.toDoListUncompletedButton:
				 * activity.setList(DatabaseFacade.getListByCompleted(activity,
				 * activity.getUser(), false)); break; case
				 * R.id.toDoListCategoryButton:
				 * activity.setCategoryVisibility(true); break;
				 */
		}

	}

	public void startEditActivity() {
		activity.startActivityForResult(
				ToDoListItem.putItemIntoIntent(
						User.putUserIntoIntent(new Intent(activity, editActivity), activity.getUser()),
						activity.getItem()), RequestCodes.editItem);
	}

	public void startCreateActivity() {
		activity.startActivityForResult(
				User.putUserIntoIntent(new Intent(activity, createActivity), activity.getUser()),
				RequestCodes.createItem);
	}

}
